﻿//*** Guidance generated code ***//
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace $safeprojectname$.Binding
{
    public class MvcValueContainer : IValueContainer
    {
        protected readonly IValueProvider ValueProvider;
        public MvcValueContainer(IValueProvider valueProvider)
        {
            ValueProvider = valueProvider;
        }

        public bool ContainsPrefix(string prefix)
        {
            return ValueProvider.ContainsPrefix(prefix);
        }

        public IValueResult GetValue(string key)
        {
            var value = ValueProvider.GetValue(key);

            return value.IsNull() 
                ? null 
                : new MvcValueResult(value);
        }

        public virtual IValueProvider ToValueProvider()
        {
            return ValueProvider;
        }
    }
}